@extends('layouts.admin')
@section('pageTitle', '位置列表')
@section('content')
    <div class="main-panel">
        <div class="content apartment-index">
            <div class="container-fluid" style="min-height:600px;">
                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="header">
                                <legend>奖品充值列表</legend>
                            </div>
                            <div class="toolbar">
                            </div>

                            <table id="bootstrap-table-container" class="table" data-url="/web/prizeRechargeRecords/list">
                                <thead>
                                <th data-field="state" data-checkbox="true"></th>
                                <th data-field="order_name" >订单名称</th>
                                <th data-field="goods_name" >商品名称</th>
                                <th data-field="price" data-sortable="true">订单单价</th>
                                <th data-field="number" data-sortable="true">订单数量</th>
                                <th data-field="prize_id" data-formatter="prizeIDFormatter">奖品名称</th>
                                <th data-field="status" data-formatter="statusFormatter">支付状态</th>
                                <th data-field="created_at" data-sortable="true" >创建时间</th>
                                </thead>
                                <tbody>

                                </tbody>
                            </table>
                        </div><!--  end card  -->
                    </div> <!-- end col-md-12 -->
                </div> <!-- end row -->
            </div>
        </div>
    </div>
@endsection
@section('script')
    <script>
        window.table_option = {
            search:false
        };
        function statusFormatter(value,row) {
            //支付状态 0未支付 1已提交支付 2支付取消 3支付成功 4 支付结束 5支付失败 6退款提交 7退款完成
            var arr = ['未支付','已提交支付','支付取消','支付成功','支付结束','支付失败','退款提交','退款完成'];
            var str = '';
            for(var i=0;i<arr.length;i++){
                if(row.status == i){
                    str = '<span class="text-warning">'+arr[i]+'</span>';
                    break;
                }
            }
            return str;
        }
        function prizeIDFormatter(value,row) {
            str = '<span class="text-success">'+row['prize']['name']+'</span>';
            return str;
        }
        window.operateEvents = {
            'click .delete':function (e,value,row) {
                var bt = document.body.querySelector('#bootstrap-table-container');
                var event = new CustomEvent("table-delete-item", { "detail": [row.id] });
                bt.dispatchEvent(event);
            }
        }
    </script>
@endsection